[NAE-2448] Migration for NAE v7 phase 2#451
Conversation
Introduce `MigrationBeansConfiguration` and remove `@Component` annotation from `MigrationHelper`
|
Warning Review limit reached
More reviews will be available in 47 minutes and 22 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesMigrationHelper Bean Registration and collectErrors Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/AbstractMigrationHelper.groovy`:
- Around line 193-195: Fix the malformed Javadoc on AbstractMigrationHelper by
removing the leading space and splitting the merged lines into a properly
formatted Javadoc description: start with /** on its own line, then each
sentence on its own line prefixed with " *", describing that the method iterates
documents, applies updates, executes bulk operations, supports pagination via
page size, allows custom bulk processing and optional sleep between pages;
ensure the closing " */" is on its own line and attach this comment to the
corresponding method in AbstractMigrationHelper.
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/CaseMigrationHelper.groovy`:
- Around line 340-361: Update the Javadoc to reference the correct parameter
name (toRemove) and guard the unsafe cast in removeChoices(Case useCase,
Map<String, List<String>> toRemove): before casting dataField.value to Set,
verify its type (e.g., instanceof Collection or Set) and only call removeAll on
it when safe; if the field holds a single String (enum) handle that case by
comparing/removing the value accordingly, and ensure you only call removeAll on
dataField.choices when dataField.choices != null as already done.
- Around line 368-381: The method changeFileFieldToFileList is casting
existingValue to FileFieldValue unsafely; update it to check the runtime type of
existingValue before adding to FileListFieldValue.namesPaths (e.g., use
instanceof or an explicit type check on existingValue) and only add when it's a
FileFieldValue, otherwise skip and optionally log a warning on dataField or
useCase to aid debugging; adjust handling in the block referencing
existingValue, FileFieldValue, FileListFieldValue, dataField and namesPaths so
no ClassCastException can occur during migration.
- Around line 443-455: The removeCase method validates MongoDB deletion but
doesn't handle failures from elasticCaseService.remove(useCase.getStringId());
wrap that call in a try-catch inside removeCase, catch Exception (or a more
specific exception if appropriate), log the error and call
handleMigrationError(errorPolicy, "removeCase", type, useCase.stringId, <error
message>) so Elasticsearch removal failures are reported using the same error
policy; ensure successful trace logging remains after the try block and return
or continue consistent with existing error handling.
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/PetriNetMigrationHelper.groovy`:
- Around line 5-15: PetriNetMigrationHelper.groovy references the unqualified
symbol VersionType (e.g. VersionType.MAJOR) but lacks its import; add the
missing import statement for
com.netgrif.application.engine.objects.petrinet.domain.VersionType to the top
import block so the Groovy compiler can resolve VersionType when used in
PetriNetMigrationHelper (search for the VersionType.MAJOR usage to verify).
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/TaskMigrationHelper.groovy`:
- Around line 235-242: The addRoleToExistingTasks method currently calls
updateTasks without forwarding the caller's error policy, causing it to always
use defaultErrorPolicy; change the call in addRoleToExistingTasks to accept and
pass an explicit ErrorPolicy argument (propagate the active policy from
MigrationHelper.withErrorPolicy) so updateTasks receives the caller's policy
instead of falling back to defaultErrorPolicy(); update the updateTasks
invocation signature usage in addRoleToExistingTasks to include the policy
parameter (and ensure MigrationHelper.withErrorPolicy callers pass their policy
through) while keeping the existing role/permissions closure unchanged.
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy`:
- Around line 600-606: collectErrors currently returns from the finally block
which swallows exceptions from migrationCode.call(); change the method to avoid
returning inside finally: call clearErrors(), declare a List<MigrationError>
variable (e.g. errors), invoke migrationCode.call() inside try, in finally
assign errors = popErrors(), and after the try/finally return errors so any
exception thrown by migrationCode.call() will propagate while still ensuring
popErrors() runs (refer to collectErrors, migrationCode.call, clearErrors,
popErrors).
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/model/MigrationError.groovy`:
- Around line 132-134: The getter getEntityType() currently declares return type
String but the field entityType is Class<?>; update the method signature to
"Class<?> getEntityType()" and return the entityType field unchanged so the
types match, i.e., change the return type to Class<?> in the getEntityType()
method (or if string semantics were intended, alternatively convert the field to
String and adjust any constructor/assignments to store a String instead).
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/model/MigrationErrorPolicy.groovy`:
- Around line 100-108: The factory method throwAfterLimit currently rejects
maxErrors <= 0 which contradicts setMaxErrors, the
MigrationProperties.ErrorPolicy javadoc and
AbstractMigrationHelper.finishMigrationErrorPolicy; update throwAfterLimit to
accept maxErrors == 0 (i.e., only reject negative values) so THROW_AFTER_LIMIT
with maxErrors == 0 is allowed and handled consistently, ensuring behavior
aligns with MigrationErrorHandlingMode.THROW_AFTER_LIMIT and the logic in
AbstractMigrationHelper.finishMigrationErrorPolicy.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: aad25209-009a-4016-9393-71fbf79e87bb
📒 Files selected for processing (17)
application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/AbstractMigrationHelper.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/CaseMigrationHelper.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/PetriNetMigrationHelper.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/helpers/TaskMigrationHelper.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/model/MigrationError.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/model/MigrationErrorHandlingMode.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/model/MigrationErrorPolicy.groovyapplication-engine/src/main/groovy/com/netgrif/application/engine/migration/throwable/MigrationErrorException.groovyapplication-engine/src/main/java/com/netgrif/application/engine/configuration/MigrationBeansConfiguration.javaapplication-engine/src/main/java/com/netgrif/application/engine/configuration/properties/MigrationProperties.javaapplication-engine/src/main/java/com/netgrif/application/engine/utils/MongodbUtils.javaapplication-engine/src/test/groovy/com/netgrif/application/engine/elastic/ElasticSearchTest.groovyapplication-engine/src/test/groovy/com/netgrif/application/engine/elastic/ElasticTaskTest.groovyapplication-engine/src/test/groovy/com/netgrif/application/engine/migration/MigrationTest.groovyapplication-engine/src/test/resources/petriNets/migration_test_v1.xmlapplication-engine/src/test/resources/petriNets/migration_test_v2.xml
💤 Files with no reviewable changes (2)
- application-engine/src/test/groovy/com/netgrif/application/engine/elastic/ElasticTaskTest.groovy
- application-engine/src/test/groovy/com/netgrif/application/engine/elastic/ElasticSearchTest.groovy
|
🎉 All dependencies have been resolved ! |
The merge-base changed after approval.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy (1)
600-606:⚠️ Potential issue | 🔴 CriticalPop the error cache inside
finally, not after it.If
migrationCode.call()throws, execution never reaches line 606, so errors collected before the failure remain cached in the sub-helpers (caseMigrationHelper, taskMigrationHelper, petriNetMigrationHelper) and can pollute latergetErrors()/hasErrors()reads. Store the popped errors infinallyto ensure cleanup always occurs; the exception still propagates after the finally block executes.Proposed fix
List<MigrationError> collectErrors(Closure migrationCode) { clearErrors() + List<MigrationError> errors = [] try { migrationCode.call() } finally { + errors = popErrors() } - return popErrors() + return errors }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy` around lines 600 - 606, The `collectErrors` method currently calls `popErrors()` after the finally block, which means if `migrationCode.call()` throws an exception, the error cache is never cleared and errors remain in the sub-helpers (caseMigrationHelper, taskMigrationHelper, petriNetMigrationHelper), polluting subsequent calls. Move the error cache cleanup into the finally block by storing the result of `popErrors()` inside the finally block and then returning it after the finally block completes. This ensures the error cache is always cleared regardless of whether an exception is thrown, while still allowing any exception to propagate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy`:
- Around line 600-606: The `collectErrors` method currently calls `popErrors()`
after the finally block, which means if `migrationCode.call()` throws an
exception, the error cache is never cleared and errors remain in the sub-helpers
(caseMigrationHelper, taskMigrationHelper, petriNetMigrationHelper), polluting
subsequent calls. Move the error cache cleanup into the finally block by storing
the result of `popErrors()` inside the finally block and then returning it after
the finally block completes. This ensures the error cache is always cleared
regardless of whether an exception is thrown, while still allowing any exception
to propagate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e74a5d6f-e0fe-4fcb-a1e1-5e146a5c2bbe
📒 Files selected for processing (1)
application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy
…ng exceptions, logging them, and including in the result
2013963
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy`:
- Around line 596-600: The Javadoc tags in the method comment are malformed—they
use backticks within braces (e.g., {`@code`, {`@link`) which won't render
correctly in generated documentation. Replace these with proper Javadoc syntax
using `@code`{...} and `@link`{...} respectively. Additionally, the documentation
claims "this method never throws" which is inaccurate since only Exception is
caught, not JVM Errors or failures in finally block cleanup. Update this
statement to accurately reflect that only Exception instances are caught and
included in the returned error list, while other exceptions and errors may still
propagate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5fec5c80-4c82-40f2-b1d3-556bb8270013
📒 Files selected for processing (1)
application-engine/src/main/groovy/com/netgrif/application/engine/migration/MigrationHelper.groovy
…on exception handling and parameter annotations
Description
Implements NAE-2448
Dependencies
No new dependencies were introduced.
Third party dependencies
No new dependencies were introduced.
Blocking Pull requests
Depends on #448
How Has Been This Tested?
This was tested manually and with unit tests.
Test Configuration
Checklist:
Summary by CodeRabbit
Release Notes